package com.seeyoui.kensite.framework.file.service.impl;

import com.google.common.collect.Lists;
import com.seeyoui.kensite.framework.file.model.FileAttribute;
import com.seeyoui.kensite.framework.file.service.FilePreview;
import com.seeyoui.kensite.framework.file.utils.FileUtils;
import com.sun.star.uno.Exception;

import org.springframework.stereotype.Service;
import org.springframework.ui.Model;

import java.util.List;

/**
 * Created by kl on 2018/1/17.
 * Content :图片文件处理
 */
@Service
public class PictureFilePreviewImpl implements FilePreview {

    FileUtils fileUtils;

    @Override
    public String[] filePreviewHandle(String url, Model model) {
        @SuppressWarnings("rawtypes")
        List imgUrls = Lists.newArrayList(url);
        FileAttribute fileAttribute = null;
        try{
            imgUrls.clear();
            fileAttribute = FileUtils.getFileAttribute(url);
        }catch (Exception e){
            imgUrls = Lists.newArrayList(url);
        }
        return new String[]{"picture","demo/"+fileAttribute.getName()};
    }
}
